package com.yc.house.controller;

import com.yc.house.model.TSUser;
import com.yc.house.service.impl.UserServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


@RestController
@RequestMapping("/test")
public class TestController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(TestController.class);

	@RequestMapping("/test01")
	public String test1(@RequestParam(required = false, defaultValue = "-1") String str) {
		return "test success" + str;
	}

	@RequestMapping("/test02/{id}")
	public String test2(@PathVariable String id) {
		return "test success" + id;
	}


	@Autowired
	private UserServiceImpl userService;

	@RequestMapping("/findCustomer")
	public TSUser findCustomer(String id) {
		return userService.findCustomer(id);
	}

	@RequestMapping("/testU")
	public ModelAndView testU(String id) {
		logger.info(request.getParameter("id"));
		System.out.println(userService.testU(id).toString());
		return new ModelAndView("test").addObject("user", userService.testU(id));
	}


}
